package com.itcm.dockerdemo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 描述:
 * 统计接口访问次数
 *
 * @author cm_fighting
 * @create 2021-10-27 下午3:09
 */

@RestController
public class CounterController {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @GetMapping("/hello")
    public String count() {
        Long increment = redisTemplate.opsForValue().increment("hello-count");
        return "该接口被访问【" + increment + "】次啦！！！";
    }
}
